﻿<UserControl x:Class="Holdem.Core.Controls.HoldemFlopCardButtonControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             d:DesignHeight="480" d:DesignWidth="480"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:MvvmLite="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP71"
             mc:Ignorable="d"
             FontFamily="{StaticResource PhoneFontFamilyNormal}"
             FontSize="{StaticResource PhoneFontSizeNormal}"
             Foreground="{StaticResource PhoneForegroundBrush}">

    <UserControl.Resources>
        <Style x:Key="ButtonOverlayTemplate" TargetType="ContentControl">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ContentControl">
                        <ContentPresenter 
							ContentTemplate="{TemplateBinding ContentTemplate}" 
							Content="{TemplateBinding Content}" 
							HorizontalAlignment="Center" 
							VerticalAlignment="Center"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="THCCardStyle" TargetType="Image">
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Stretch" Value="Fill" />
            <Setter Property="Height" Value="118" />
            <Setter Property="Width" Value="84" />
            <Setter Property="Source" Value="Back.png" />
        </Style>
        <Style x:Key="NoBorderButton" TargetType="Button">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid Background="Transparent">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal">
                                        <!--<Storyboard x:Name="AnimateCardVertical">
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" 
											Storyboard.TargetName="ButtonBackground">
                                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90"/>
                                            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="180"/>
                                            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="270"/>
                                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="360"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>-->
                                    </VisualState>
                                    <VisualState x:Name="MouseOver" />
                                    <VisualState x:Name="Pressed">
                                        <!--<Storyboard x:Name="AnimateCardVerticalHorizontal">
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" 
											Storyboard.TargetName="ButtonBackground">
                                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90"/>
                                            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="180"/>
                                            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="270"/>
                                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="360"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>-->
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames 
											Storyboard.TargetProperty="Foreground" 
											Storyboard.TargetName="ContentContainer">
                                                <DiscreteObjectKeyFrame 
												KeyTime="0" 
												Value="{StaticResource PhoneDisabledBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames 
											Storyboard.TargetProperty="BorderBrush" 
											Storyboard.TargetName="ButtonBackground">
                                                <DiscreteObjectKeyFrame 
												KeyTime="0" 
												Value="{StaticResource PhoneDisabledBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames 
											Storyboard.TargetProperty="Background" 
											Storyboard.TargetName="ButtonBackground">
                                                <DiscreteObjectKeyFrame 
												KeyTime="0" 
												Value="Transparent"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="ButtonBackground" 
							BorderBrush="{TemplateBinding BorderBrush}" 
							Background="{TemplateBinding Background}" 
							CornerRadius="0">
                                <Border.Projection>
                                    <PlaneProjection />
                                </Border.Projection>
                                <ContentControl x:Name="ContentContainer" 
								ContentTemplate="{TemplateBinding ContentTemplate}" 
								Content="{TemplateBinding Content}" 
								Foreground="{TemplateBinding Foreground}" 
								HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
								Padding="{TemplateBinding Padding}" 
								VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" 
								Style="{StaticResource ButtonOverlayTemplate}"/>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="THCCardOverlayStyle" TargetType="Button" BasedOn="{StaticResource NoBorderButton}" >
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
            <Setter Property="Height" Value="118" />
            <Setter Property="Width" Value="84" />
        </Style>
    </UserControl.Resources>
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="VisualStateGroupVertical">
            <VisualStateGroup.Transitions>
                <VisualTransition GeneratedDuration="0">
                    <Storyboard x:Name="AnimateCardVerticalFlopOne">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardImageButtonOne" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="180" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="270" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="360" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualTransition>
                <VisualTransition GeneratedDuration="0">
                    <Storyboard x:Name="AnimateCardVerticalFlopTwo">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardImageButtonTwo" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="180" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="270" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="360" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualTransition>
                <VisualTransition GeneratedDuration="0">
                    <Storyboard x:Name="AnimateCardVerticalFlopThree">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardImageButtonThree" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="180" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="270" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="360" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualTransition>
                <VisualTransition GeneratedDuration="0">
                    <Storyboard x:Name="AnimateCardVerticalTurn">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardImageButtonFour" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="180" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="270" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="360" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualTransition>
                <VisualTransition GeneratedDuration="0">
                    <Storyboard x:Name="AnimateCardVerticalRiver">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardImageButtonFive" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="180" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="270" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="360" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualTransition>
            </VisualStateGroup.Transitions>
        </VisualStateGroup>
        <VisualStateGroup x:Name="VisualStateGroupHorizontal">
            <VisualStateGroup.Transitions>
                <VisualTransition GeneratedDuration="0">
                    <Storyboard x:Name="AnimateCardHorizontalFlopOne">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardImageButtonOne" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="180" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="270" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="360" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualTransition>
                <VisualTransition GeneratedDuration="0">
                    <Storyboard x:Name="AnimateCardHorizontalFlopTwo">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardImageButtonTwo" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="180" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="270" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="360" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualTransition>
                <VisualTransition GeneratedDuration="0">
                    <Storyboard x:Name="AnimateCardHorizontalFlopThree">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardImageButtonThree" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="180" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="270" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="360" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualTransition>
                <VisualTransition GeneratedDuration="0">
                    <Storyboard x:Name="AnimateCardHorizontalTurn">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardImageButtonFour" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="180" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="270" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="360" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualTransition>
                <VisualTransition GeneratedDuration="0">
                    <Storyboard x:Name="AnimateCardHorizontalRiver">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardImageButtonFive" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="180" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="270" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="360" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualTransition>
            </VisualStateGroup.Transitions>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <StackPanel x:Name="HoldemFlopCardStackPanel" 
                Orientation="{Binding Orientation}"
                DataContext="{Binding}"
                HorizontalAlignment="{Binding HorizontalAlignment}">
        <Button x:Name="CardImageButtonOne" Margin="2"
                Style="{StaticResource THCCardOverlayStyle}" 
                HorizontalAlignment="Center" BorderThickness="0">
            <Button.Projection>
                <PlaneProjection />
            </Button.Projection>
            <Image x:Name="CardImageOne" 
                   Source="{Binding ItemSource[0]}" 
                   Style="{StaticResource THCCardStyle}">
                <Image.Projection>
                    <PlaneProjection />
                </Image.Projection>
            </Image>
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <MvvmLite:EventToCommand x:Name="CardImageOverlayOne" 
                                             Command="{Binding CardImageCommandOne}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>

        <Button x:Name="CardImageButtonTwo" Margin="2"
                        Style="{StaticResource THCCardOverlayStyle}" BorderThickness="0">
            <Button.Projection>
                <PlaneProjection />
            </Button.Projection>
            <Image x:Name="CardImageTwo" 
                   Source="{Binding ItemSource[1]}" 
                   Style="{StaticResource THCCardStyle}">
                <Image.Projection>
                    <PlaneProjection />
                </Image.Projection>
            </Image>
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <MvvmLite:EventToCommand x:Name="CardImageOverlayTwo" 
                                             Command="{Binding CardImageCommandTwo}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>

        <Button x:Name="CardImageButtonThree" Margin="2"
                        Style="{StaticResource THCCardOverlayStyle}" BorderThickness="0">
            <Button.Projection>
                <PlaneProjection />
            </Button.Projection>
            <Image x:Name="CardImageThree" 
                   Source="{Binding ItemSource[2]}" 
                   Style="{StaticResource THCCardStyle}">
                <Image.Projection>
                    <PlaneProjection />
                </Image.Projection>
            </Image>
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <MvvmLite:EventToCommand x:Name="CardImageOverlayThree" 
                                             Command="{Binding CardImageCommandThree}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>

        <Button x:Name="CardImageButtonFour" Margin="2"
                        Style="{StaticResource THCCardOverlayStyle}" BorderThickness="0">
            <Button.Projection>
                <PlaneProjection />
            </Button.Projection>
            <Image x:Name="CardImageFour" 
                   Source="{Binding ItemSource[3]}" 
                   Style="{StaticResource THCCardStyle}">
                <Image.Projection>
                    <PlaneProjection />
                </Image.Projection>
            </Image>
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <MvvmLite:EventToCommand x:Name="CardImageOverlayFour" 
                                             Command="{Binding CardImageCommandFour}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>

        <Button x:Name="CardImageButtonFive" Margin="2"
                        Style="{StaticResource THCCardOverlayStyle}" BorderThickness="0">
            <Button.Projection>
                <PlaneProjection />
            </Button.Projection>
            <Image x:Name="CardImageFive" 
                   Source="{Binding ItemSource[4]}" 
                   Style="{StaticResource THCCardStyle}">
                <Image.Projection>
                    <PlaneProjection />
                </Image.Projection>
            </Image>
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <MvvmLite:EventToCommand x:Name="CardImageOverlayFive" 
                                             Command="{Binding CardImageCommandFive}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>

    </StackPanel>
</UserControl>
